<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        //服务器返回数据    
        let res = [
            {
                "id": 1796,
                "name": "魏平",
                "sex": "女",
                "age": 25,
                "group": 1,
                "phone": "13766245366",
                "salary": 10238,
                "truesalary": 8977,
                "province": "河南省",
                "city": "洛阳市",
                "county": "西工区",
                "user_id": 42,
                "jing": 112.428413,
                "wei": 34.6599
            },
            {
                "id": 1797,
                "name": "锺敏",
                "sex": "男",
                "age": 21,
                "group": 2,
                "phone": "15142633127",
                "salary": 6271,
                "truesalary": 9930,
                "province": "新疆维吾尔自治区",
                "city": "吐鲁番市",
                "county": "托克逊县",
                "user_id": 42,
                "jing": 88.638816,
                "wei": 42.792454
            },
            {
                "id": 1798,
                "name": "郝杰",
                "sex": "女",
                "age": 28,
                "group": 3,
                "phone": "15564747713",
                "salary": 18859,
                "truesalary": 6985,
                "province": "甘肃省",
                "city": "金昌市",
                "county": "金川区",
                "user_id": 42,
                "jing": 102.194089,
                "wei": 38.521085
            },
            {
                "id": 1799,
                "name": "黎丽",
                "sex": "男",
                "age": 20,
                "group": 4,
                "phone": "13759343968",
                "salary": 18314,
                "truesalary": 16273,
                "province": "西藏自治区",
                "city": "昌都市",
                "county": "卡若区",
                "user_id": 42,
                "jing": 97.180437,
                "wei": 31.138507
            },
            {
                "id": 1800,
                "name": "石艳",
                "sex": "男",
                "age": 26,
                "group": 5,
                "phone": "13376150627",
                "salary": 11400,
                "truesalary": 7161,
                "province": "新疆维吾尔自治区",
                "city": "哈密市",
                "county": "伊州区",
                "user_id": 42,
                "jing": 93.514797,
                "wei": 42.827255
            },
            {
                "id": 1801,
                "name": "于勇",
                "sex": "女",
                "age": 26,
                "group": 6,
                "phone": "13910576576",
                "salary": 15271,
                "truesalary": 14064,
                "province": "河北省",
                "city": "石家庄市",
                "county": "长安区",
                "user_id": 42,
                "jing": 114.53906,
                "wei": 38.036654
            },
            {
                "id": 1802,
                "name": "陈静",
                "sex": "女",
                "age": 23,
                "group": 7,
                "phone": "15122513833",
                "salary": 15534,
                "truesalary": 15499,
                "province": "江苏省",
                "city": "无锡市",
                "county": "锡山区",
                "user_id": 42,
                "jing": 120.357858,
                "wei": 31.589715
            },
            {
                "id": 1803,
                "name": "段秀兰",
                "sex": "男",
                "age": 29,
                "group": 8,
                "phone": "13238371130",
                "salary": 11468,
                "truesalary": 13324,
                "province": "河南省",
                "city": "洛阳市",
                "county": "西工区",
                "user_id": 42,
                "jing": 112.428413,
                "wei": 34.6599
            },
            {
                "id": 1804,
                "name": "万强",
                "sex": "女",
                "age": 18,
                "group": 1,
                "phone": "13146036107",
                "salary": 16400,
                "truesalary": 15347,
                "province": "广西壮族自治区",
                "city": "柳州市",
                "county": "融水苗族自治县",
                "user_id": 42,
                "jing": 109.256334,
                "wei": 25.065934
            },
            {
                "id": 1805,
                "name": "刘洋",
                "sex": "女",
                "age": 29,
                "group": 2,
                "phone": "13561664886",
                "salary": 16989,
                "truesalary": 8361,
                "province": "湖南省",
                "city": "衡阳市",
                "county": "衡山县",
                "user_id": 42,
                "jing": 112.868268,
                "wei": 27.230291
            },
            {
                "id": 1806,
                "name": "段秀英",
                "sex": "男",
                "age": 19,
                "group": 3,
                "phone": "13447411447",
                "salary": 18566,
                "truesalary": 18760,
                "province": "江苏省",
                "city": "无锡市",
                "county": "锡山区",
                "user_id": 42,
                "jing": 120.357858,
                "wei": 31.589715
            },
            {
                "id": 1807,
                "name": "侯静",
                "sex": "女",
                "age": 27,
                "group": 4,
                "phone": "13138615163",
                "salary": 8784,
                "truesalary": 18400,
                "province": "广西壮族自治区",
                "city": "柳州市",
                "county": "融安县",
                "user_id": 42,
                "jing": 109.397538,
                "wei": 25.22455
            },
            {
                "id": 1808,
                "name": "卢涛",
                "sex": "男",
                "age": 23,
                "group": 5,
                "phone": "17863421913",
                "salary": 14508,
                "truesalary": 15363,
                "province": "江苏省",
                "city": "无锡市",
                "county": "锡山区",
                "user_id": 42,
                "jing": 120.357858,
                "wei": 31.589715
            },
            {
                "id": 1809,
                "name": "常勇",
                "sex": "男",
                "age": 21,
                "group": 6,
                "phone": "13823114828",
                "salary": 11330,
                "truesalary": 7120,
                "province": "湖南省",
                "city": "衡阳市",
                "county": "衡山县",
                "user_id": 42,
                "jing": 112.868268,
                "wei": 27.230291
            },
            {
                "id": 1810,
                "name": "冯秀英",
                "sex": "男",
                "age": 21,
                "group": 7,
                "phone": "15516894363",
                "salary": 19244,
                "truesalary": 13391,
                "province": "内蒙古自治区",
                "city": "包头市",
                "county": "东河区",
                "user_id": 42,
                "jing": 110.044142,
                "wei": 40.575948
            },
            {
                "id": 1811,
                "name": "吴军",
                "sex": "女",
                "age": 27,
                "group": 8,
                "phone": "13316461468",
                "salary": 11537,
                "truesalary": 11921,
                "province": "湖南省",
                "city": "株洲市",
                "county": "荷塘区",
                "user_id": 42,
                "jing": 113.173487,
                "wei": 27.855929
            },
            {
                "id": 1812,
                "name": "蔡涛",
                "sex": "男",
                "age": 24,
                "group": 1,
                "phone": "13960917047",
                "salary": 17384,
                "truesalary": 6130,
                "province": "云南省",
                "city": "昆明市",
                "county": "安宁市",
                "user_id": 42,
                "jing": 102.478494,
                "wei": 24.919493
            },
            {
                "id": 1813,
                "name": "顾芳",
                "sex": "女",
                "age": 29,
                "group": 2,
                "phone": "13319857392",
                "salary": 17826,
                "truesalary": 15159,
                "province": "江苏省",
                "city": "宿迁市",
                "county": "宿豫区",
                "user_id": 42,
                "jing": 118.330782,
                "wei": 33.946822
            },
            {
                "id": 1814,
                "name": "乔洋",
                "sex": "女",
                "age": 23,
                "group": 3,
                "phone": "15167245544",
                "salary": 12159,
                "truesalary": 11374,
                "province": "山东省",
                "city": "青岛市",
                "county": "市南区",
                "user_id": 42,
                "jing": 120.385649,
                "wei": 36.080305
            },
            {
                "id": 1815,
                "name": "石芳",
                "sex": "男",
                "age": 19,
                "group": 4,
                "phone": "15113666889",
                "salary": 12036,
                "truesalary": 18926,
                "province": "西藏自治区",
                "city": "昌都市",
                "county": "卡若区",
                "user_id": 42,
                "jing": 97.180437,
                "wei": 31.138507
            },
            {
                "id": 1816,
                "name": "白娜",
                "sex": "男",
                "age": 27,
                "group": 5,
                "phone": "15512854542",
                "salary": 7024,
                "truesalary": 6197,
                "province": "广西壮族自治区",
                "city": "桂林市",
                "county": "资源县",
                "user_id": 42,
                "jing": 110.6527,
                "wei": 26.042443
            },
            {
                "id": 1817,
                "name": "谢刚",
                "sex": "男",
                "age": 24,
                "group": 6,
                "phone": "15194972829",
                "salary": 16739,
                "truesalary": 16535,
                "province": "山东省",
                "city": "济南市",
                "county": "历下区",
                "user_id": 42,
                "jing": 117.076455,
                "wei": 36.666412
            },
            {
                "id": 1818,
                "name": "梁平",
                "sex": "男",
                "age": 24,
                "group": 7,
                "phone": "13451405709",
                "salary": 11324,
                "truesalary": 19269,
                "province": "甘肃省",
                "city": "兰州市",
                "county": "榆中县",
                "user_id": 42,
                "jing": 104.112527,
                "wei": 35.843056
            },
            {
                "id": 1819,
                "name": "侯娜",
                "sex": "女",
                "age": 29,
                "group": 8,
                "phone": "13825840151",
                "salary": 7289,
                "truesalary": 11432,
                "province": "甘肃省",
                "city": "嘉峪关市",
                "county": "雄关区",
                "user_id": 42,
                "jing": 98.274891,
                "wei": 39.783332
            },
            {
                "id": 1820,
                "name": "熊勇",
                "sex": "男",
                "age": 24,
                "group": 1,
                "phone": "13651314757",
                "salary": 10347,
                "truesalary": 8982,
                "province": "湖南省",
                "city": "株洲市",
                "county": "芦淞区",
                "user_id": 42,
                "jing": 113.152724,
                "wei": 27.78507
            },
            {
                "id": 1821,
                "name": "蒋勇",
                "sex": "男",
                "age": 28,
                "group": 2,
                "phone": "15027170842",
                "salary": 16939,
                "truesalary": 6887,
                "province": "黑龙江省",
                "city": "佳木斯市",
                "county": "向阳区",
                "user_id": 42,
                "jing": 130.365346,
                "wei": 46.80779
            },
            {
                "id": 1822,
                "name": "田芳",
                "sex": "男",
                "age": 27,
                "group": 3,
                "phone": "15059171764",
                "salary": 19948,
                "truesalary": 19779,
                "province": "广西壮族自治区",
                "city": "南宁市",
                "county": "兴宁区",
                "user_id": 42,
                "jing": 108.368871,
                "wei": 22.854021
            },
            {
                "id": 1823,
                "name": "曹洋",
                "sex": "男",
                "age": 21,
                "group": 4,
                "phone": "13650125811",
                "salary": 12209,
                "truesalary": 14808,
                "province": "江苏省",
                "city": "宿迁市",
                "county": "沭阳县",
                "user_id": 42,
                "jing": 118.804784,
                "wei": 34.111022
            },
            {
                "id": 1824,
                "name": "吕秀英",
                "sex": "女",
                "age": 23,
                "group": 5,
                "phone": "13021074052",
                "salary": 14988,
                "truesalary": 13000,
                "province": "云南省",
                "city": "曲靖市",
                "county": "会泽县",
                "user_id": 42,
                "jing": 103.297361,
                "wei": 26.417947
            },
            {
                "id": 1825,
                "name": "戴静",
                "sex": "女",
                "age": 22,
                "group": 6,
                "phone": "15104424212",
                "salary": 7853,
                "truesalary": 6536,
                "province": "甘肃省",
                "city": "嘉峪关市",
                "county": "雄关区",
                "user_id": 42,
                "jing": 98.274891,
                "wei": 39.783332
            },
            {
                "id": 1826,
                "name": "范丽",
                "sex": "男",
                "age": 20,
                "group": 7,
                "phone": "13922418388",
                "salary": 13752,
                "truesalary": 10573,
                "province": "江苏省",
                "city": "无锡市",
                "county": "锡山区",
                "user_id": 42,
                "jing": 120.357858,
                "wei": 31.589715
            },
            {
                "id": 1827,
                "name": "彭丽",
                "sex": "女",
                "age": 30,
                "group": 8,
                "phone": "13216671420",
                "salary": 14474,
                "truesalary": 13726,
                "province": "云南省",
                "city": "曲靖市",
                "county": "会泽县",
                "user_id": 42,
                "jing": 103.297361,
                "wei": 26.417947
            },
            {
                "id": 1828,
                "name": "黎强",
                "sex": "男",
                "age": 20,
                "group": 1,
                "phone": "15022781578",
                "salary": 14280,
                "truesalary": 12879,
                "province": "广东省",
                "city": "广州市",
                "county": "越秀区",
                "user_id": 42,
                "jing": 113.266841,
                "wei": 23.128524
            },
            {
                "id": 1829,
                "name": "孟勇",
                "sex": "男",
                "age": 27,
                "group": 2,
                "phone": "13622689437",
                "salary": 15668,
                "truesalary": 8984,
                "province": "湖南省",
                "city": "湘潭市",
                "county": "雨湖区",
                "user_id": 42,
                "jing": 112.903317,
                "wei": 27.854705
            },
            {
                "id": 1830,
                "name": "魏勇",
                "sex": "女",
                "age": 20,
                "group": 3,
                "phone": "13116585778",
                "salary": 6073,
                "truesalary": 14751,
                "province": "黑龙江省",
                "city": "牡丹江市",
                "county": "东安区",
                "user_id": 42,
                "jing": 129.626642,
                "wei": 44.58136
            },
            {
                "id": 1831,
                "name": "袁丽",
                "sex": "女",
                "age": 23,
                "group": 4,
                "phone": "15049713850",
                "salary": 11520,
                "truesalary": 16301,
                "province": "西藏自治区",
                "city": "阿里地区",
                "county": "改则县",
                "user_id": 42,
                "jing": 84.06259,
                "wei": 32.302713
            },
            {
                "id": 1832,
                "name": "萧明",
                "sex": "男",
                "age": 25,
                "group": 5,
                "phone": "13378120572",
                "salary": 14232,
                "truesalary": 15986,
                "province": "广西壮族自治区",
                "city": "桂林市",
                "county": "资源县",
                "user_id": 42,
                "jing": 110.6527,
                "wei": 26.042443
            },
            {
                "id": 1833,
                "name": "董静",
                "sex": "女",
                "age": 20,
                "group": 6,
                "phone": "13496076514",
                "salary": 14113,
                "truesalary": 14377,
                "province": "内蒙古自治区",
                "city": "阿拉善盟",
                "county": "额济纳旗",
                "user_id": 42,
                "jing": 101.05559,
                "wei": 41.954347
            },
            {
                "id": 1834,
                "name": "于秀英",
                "sex": "男",
                "age": 25,
                "group": 7,
                "phone": "13347460730",
                "salary": 14035,
                "truesalary": 10269,
                "province": "云南省",
                "city": "昆明市",
                "county": "安宁市",
                "user_id": 42,
                "jing": 102.478494,
                "wei": 24.919493
            },
            {
                "id": 1835,
                "name": "宋娟",
                "sex": "女",
                "age": 25,
                "group": 8,
                "phone": "17827663349",
                "salary": 6526,
                "truesalary": 15398,
                "province": "甘肃省",
                "city": "兰州市",
                "county": "城关区",
                "user_id": 42,
                "jing": 103.825255,
                "wei": 36.057054
            },
            {
                "id": 1836,
                "name": "刘杰",
                "sex": "男",
                "age": 28,
                "group": 1,
                "phone": "15070432473",
                "salary": 7471,
                "truesalary": 12310,
                "province": "江苏省",
                "city": "南京市",
                "county": "玄武区",
                "user_id": 42,
                "jing": 118.797861,
                "wei": 32.048687
            },
            {
                "id": 1837,
                "name": "乔秀兰",
                "sex": "女",
                "age": 20,
                "group": 2,
                "phone": "18980685828",
                "salary": 17636,
                "truesalary": 7997,
                "province": "山东省",
                "city": "淄博市",
                "county": "淄川区",
                "user_id": 42,
                "jing": 117.966723,
                "wei": 36.643452
            },
            {
                "id": 1838,
                "name": "石艳",
                "sex": "女",
                "age": 26,
                "group": 3,
                "phone": "13232234873",
                "salary": 6033,
                "truesalary": 15846,
                "province": "黑龙江省",
                "city": "七台河市",
                "county": "新兴区",
                "user_id": 42,
                "jing": 130.932143,
                "wei": 45.81593
            },
            {
                "id": 1839,
                "name": "侯芳",
                "sex": "男",
                "age": 22,
                "group": 4,
                "phone": "15177653809",
                "salary": 12901,
                "truesalary": 9116,
                "province": "山东省",
                "city": "淄博市",
                "county": "淄川区",
                "user_id": 42,
                "jing": 117.966723,
                "wei": 36.643452
            },
            {
                "id": 1840,
                "name": "赵强",
                "sex": "女",
                "age": 21,
                "group": 5,
                "phone": "15545532864",
                "salary": 13845,
                "truesalary": 9383,
                "province": "西藏自治区",
                "city": "阿里地区",
                "county": "改则县",
                "user_id": 42,
                "jing": 84.06259,
                "wei": 32.302713
            },
            {
                "id": 1841,
                "name": "任秀兰",
                "sex": "女",
                "age": 25,
                "group": 6,
                "phone": "13549434318",
                "salary": 12792,
                "truesalary": 18225,
                "province": "内蒙古自治区",
                "city": "乌海市",
                "county": "海勃湾区",
                "user_id": 42,
                "jing": 106.822779,
                "wei": 39.691156
            },
            {
                "id": 1842,
                "name": "郝芳",
                "sex": "女",
                "age": 28,
                "group": 7,
                "phone": "17828904645",
                "salary": 11653,
                "truesalary": 11077,
                "province": "湖南省",
                "city": "湘潭市",
                "county": "雨湖区",
                "user_id": 42,
                "jing": 112.903317,
                "wei": 27.854705
            },
            {
                "id": 1843,
                "name": "阎秀英",
                "sex": "女",
                "age": 21,
                "group": 8,
                "phone": "13566156461",
                "salary": 10283,
                "truesalary": 10514,
                "province": "山东省",
                "city": "青岛市",
                "county": "市北区",
                "user_id": 42,
                "jing": 120.374731,
                "wei": 36.087609
            },
            {
                "id": 1844,
                "name": "刘艳",
                "sex": "男",
                "age": 23,
                "group": 1,
                "phone": "13773563112",
                "salary": 18071,
                "truesalary": 14614,
                "province": "广东省",
                "city": "深圳市",
                "county": "罗湖区",
                "user_id": 42,
                "jing": 114.131764,
                "wei": 22.548171
            },
            {
                "id": 1845,
                "name": "赖娜",
                "sex": "男",
                "age": 27,
                "group": 2,
                "phone": "13459555413",
                "salary": 9517,
                "truesalary": 16908,
                "province": "西藏自治区",
                "city": "阿里地区",
                "county": "改则县",
                "user_id": 42,
                "jing": 84.06259,
                "wei": 32.302713
            },
            {
                "id": 1846,
                "name": "雷静",
                "sex": "男",
                "age": 22,
                "group": 3,
                "phone": "13855240158",
                "salary": 8274,
                "truesalary": 15774,
                "province": "云南省",
                "city": "玉溪市",
                "county": "元江哈尼族彝族傣族自治县",
                "user_id": 42,
                "jing": 101.998103,
                "wei": 23.596503
            },
            {
                "id": 1847,
                "name": "顾涛",
                "sex": "女",
                "age": 27,
                "group": 4,
                "phone": "13422564424",
                "salary": 12421,
                "truesalary": 13599,
                "province": "广东省",
                "city": "韶关市",
                "county": "武江区",
                "user_id": 42,
                "jing": 113.587774,
                "wei": 24.792924
            },
            {
                "id": 1848,
                "name": "尹娜",
                "sex": "女",
                "age": 25,
                "group": 5,
                "phone": "15557333693",
                "salary": 9690,
                "truesalary": 9208,
                "province": "黑龙江省",
                "city": "佳木斯市",
                "county": "向阳区",
                "user_id": 42,
                "jing": 130.365346,
                "wei": 46.80779
            },
            {
                "id": 1849,
                "name": "石芳",
                "sex": "女",
                "age": 19,
                "group": 6,
                "phone": "13366304284",
                "salary": 6663,
                "truesalary": 8463,
                "province": "湖南省",
                "city": "衡阳市",
                "county": "衡山县",
                "user_id": 42,
                "jing": 112.868268,
                "wei": 27.230291
            },
            {
                "id": 1850,
                "name": "夏洋",
                "sex": "男",
                "age": 21,
                "group": 7,
                "phone": "15079172764",
                "salary": 17189,
                "truesalary": 12016,
                "province": "新疆维吾尔自治区",
                "city": "克拉玛依市",
                "county": "乌尔禾区",
                "user_id": 42,
                "jing": 85.693742,
                "wei": 46.089148
            },
            {
                "id": 1851,
                "name": "石明",
                "sex": "男",
                "age": 21,
                "group": 8,
                "phone": "13992446110",
                "salary": 12817,
                "truesalary": 10579,
                "province": "广东省",
                "city": "韶关市",
                "county": "浈江区",
                "user_id": 42,
                "jing": 113.611098,
                "wei": 24.804381
            }
        ]
    
        //需求: 统计res对象数组中, 省的次数。
        //结果得到一个对象数组: [ { value:次数 , name:省 } ]
        let pieArr = []

        //1.遍历res,找出所有的省
        res.forEach( item=>{
            console.log( item.province )//所有学员的省
            //2.判断当前省 在不在pieArr中  ( 知识点:判断数组中是否有某个元素 )
            let index = pieArr.findIndex(ele=> ele.name == item.province )
            if( index == -1){//不在
                //添加元素, 默认value为1
                pieArr.push( {
                    name : item.province,
                    value : 1
                } )
            }else{//在, index就是下标
                pieArr[index].value++
            }
        } )

        console.log(pieArr)
        

    </script>
</body>

</html>